home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / bset11.zip / BSET.DOC next >
Text File  |  1989-11-29  |  8KB  |  189 lines

  1.  
  2.                                     BSET
  3.                                     v1.10
  4.                          Copyright 1989, Brad Stephenson
  5.  
  6.  
  7.     I've often wanted a way to exceed the DOS limitation of 127 characters 
  8.     for an environment variable.  Most of the time I wanted to be able to 
  9.     set my DOS PATH to include a large number of directories without 
  10.     resorting to the SUBST command. 
  11.  
  12.     BSET (Big SET) provides that ability.  It reads strings from a data 
  13.     file and places those strings in the "parent" environment.  It's as if 
  14.     you typed in the strings on the command line using the SET command, 
  15. |   except you are limited to 1023 characters, not 127. 
  16.  
  17.     DOS can and will use a PATH longer than 127 characters - it's only the 
  18.     SET command that limits you.  My own PATH is now 265 characters; I've 
  19.     seen no adverse effects. 
  20.  
  21. |   BSET's syntax is:     BSET [filename]
  22.  
  23.         where 'filename' is the data file containing your environment 
  24.         strings.
  25.  
  26. |   If no data file name is entered on the command line, BSET shows the
  27. |   contents of the environment.  This feature will be of use to those 
  28. |   using DOS version 4.0x - it's SET command truncates the display of
  29. |   environment variables at 127 bytes (you can still use longer variables
  30. |   with DOS 4.0x, but you cannot see their contents using SET).  BSET's 
  31. |   environment display will show the entire variable.
  32.  
  33. |   A BSET data file can contain strings that are up to 1023 characters
  34.     long.  Do not allow your word processor to wrap long lines.  Each 
  35.     string must be terminated in a CR/LF character.  Use the same syntax 
  36.     you would use with the DOS SET command (varname=varstring).
  37.  
  38.     BSET will delete an environment variable if there are no characters 
  39.     after the '=' (see example).  If you specify a variable name that 
  40.     already exists in the environment, the old variable will be deleted 
  41.     and the new one added. 
  42.  
  43.  
  44.    EXAMPLE DATA FILE CONTENTS:
  45.  
  46.        path=c:\lang\turboc
  47.        qmodem=c:\qmodem
  48. |      comprog2=
  49. |      prompt=$p$g
  50.  
  51.     In the example, the environment variables PATH and QMODEM are added 
  52. |   to the environment, COMPROG2 is deleted, and a PROMPT is set.
  53.  
  54.  
  55.                                    BSET
  56.                                   Page 2
  57.  
  58.  
  59.    ERROR HANDLING
  60.  
  61.     BSET produces error messages and DOS Errorlevel codes when it 
  62.     encounters problems.  If you exceed available environment space, for 
  63.     example, BSET will display an error message, then proceed with the 
  64.     next string in the data file. 
  65.  
  66.     The DOS Errorlevel returned reflects the last error found.  BSET will 
  67.     return the following values: 
  68.  
  69.              0 - No problems
  70.              1 - DOS version is not 2.0 or higher
  71.              2 - Insufficient room in the environment
  72.              3 - Environment string data is invalid
  73.              4 - DOS environment table is corrupted (before any changes)
  74.              5 - Data file name not specified on command line
  75.              6 - Data file cannot be found
  76.  
  77.  
  78.    ENVIRONMENT SIZE
  79.  
  80.     If you are having problems running out of environment space, use the 
  81.     SHELL command in your CONFIG.SYS file.  A typical SHELL command: 
  82.  
  83.                   SHELL=C:\DOS\COMMAND.COM /P /E:400
  84.  
  85.     For DOS 3.21, the '/E:400' expands the environment space to 400 bytes.  
  86.     For DOS version 3.1, the '/E' value specifies the number of 16-byte 
  87.     paragraphs, not the total number of bytes.  See your DOS manual for 
  88.     details. 
  89.  
  90.     If your are attempting to modify an environment from a secondary copy 
  91.     of COMMAND (as in a "drop-to-DOS" mode from another application), you 
  92.     might be surprised to find insufficient room.  This is due to the 
  93.     method DOS uses to copy the environment to a child process.  In 
  94.     general, DOS uses the following rules when establishing environment 
  95.     space for a child process: 
  96.  
  97.  
  98.            1.  If the master environment has not been expanded using the
  99.                SHELL command, a child process will receive an environment
  100.                that is 160 bytes long (differs with some older versions
  101.                of DOS).  This "baseline" size is kept even if less than
  102.                160 bytes of strings are actually in the master environment.
  103.  
  104.            2.  If the master environment has been expanded, a child process
  105.                receives all the environment strings from the parent (if
  106.                the EXEC call is set up to do so), but the total size of
  107.                the passed environment is NOT the size specified in the
  108.                SHELL command.  The total size is actually the number of
  109.                bytes USED in the master environment plus enough slack
  110.                to fill to the next paragraph (16 bytes) boundary.
  111.  
  112.  
  113.                                    BSET
  114.                                   Page 3
  115.  
  116.  
  117.  
  118.     Therefore, if you need the ability to add environment variables when 
  119.     running a secondary copy of COMMAND.COM, you should add 'dummy' 
  120.     variables to the master environment.  DOS will then create a larger 
  121.     environment for the child process.  When you are ready to modify the 
  122.     environment from the secondary copy of COMMAND, first delete the 'dummy' 
  123.     and then add your new variable. 
  124.  
  125.  
  126.    USING BSET IN AN AUTOEXEC FILE
  127.  
  128.     You should be aware of a couple of DOS idiosyncrasies when using BSET 
  129.     in an AUTOEXEC.BAT.  First, do NOT use BSET to set up your COMSPEC 
  130.     variable!  Your system will probably hang.  Second, make sure you have 
  131.     a small PATH already set up before using BSET to create your long PATH
  132.     variable.  The PATH should be the last entry in the environment when 
  133.     calling BSET (this requirement only exists if you are using BSET in an 
  134.     AUTOEXEC.BAT). 
  135.  
  136.     The following is an excerpt from my functioning AUTOEXEC.BAT file:
  137.      
  138.                    CD \STARTUP
  139.                    SET COMSPEC=C:\DOS\COMMAND.COM
  140. |                  PATH=C:\DOS
  141.                    BSET BRAD.DAT
  142.                    .
  143.                    .
  144.                    .
  145.  
  146. |   The PROMPT statement also requires some special consideration.  
  147. |   Normally your AUTOEXEC.BAT file has the statement 'PROMPT promptstring'.  
  148. |   Note that there is no '=' sign.  If you are using BSET to set your 
  149. |   PROMPT, be sure to format it as an environment variable 
  150. |   (varname=varstring).  An example of a correct PROMPT statement in a 
  151. |   BSET data file is 'PROMPT=$p$g'. 
  152.  
  153.  
  154.  
  155.                                    BSET
  156.                                   Page 4
  157.  
  158.  
  159.                     
  160.    MODIFICATION HISTORY
  161.  
  162.     Version 1.01 - Corrected problem of not incrementing line count for
  163.     11/19/89       blank lines.
  164.  
  165.                    Added routine to check for '=', '|', '<', and '>' in
  166.                    environment variable data portion of string.  If those
  167.                    characters are found, data is invalid.
  168.  
  169. |   Version 1.10 - Added the ability to display the contents of the 
  170. |   11/29/89       environment.  Also added the display of environment
  171. |                  size (total, used, free) information.
  172.  
  173.  
  174.    PROGRAM INFORMATION
  175.  
  176.     BSET uses an algorithm similar (but not identical) to one shown in 
  177.     Barry Simon's article in PC Magazine Volume 8 Number 20.  Refer to 
  178.     that article for information on finding the "parent" DOS environment. 
  179.  
  180.     BSET is free software.  The author retains all rights to the program, 
  181.     but you may distribute BSET as long as there is no fee charged. 
  182.  
  183.  
  184.                             Brad Stephenson
  185.                              670 Edgeworth
  186.                            Jenison, MI 49428
  187.                         Compuserve ID 71620,1035
  188.  
  189.